import type {
  DataPermission,
  ExtensibleEntityDto,
  ExtensibleObject,
  IEntityDto,
  IHasConcurrencyStamp,
  PagedAndSortedResultRequestDto
} from '../type';

export interface IdentityRoleCreateOrUpdateDtoBase extends ExtensibleObject {
  name: string;
  isDefault: boolean;
  isPublic: boolean;
}

export interface UpdatePermissionDto {
  name: string;
  isGranted: boolean;
}

export interface IdentityRoleCreateDto extends IdentityRoleCreateOrUpdateDtoBase { }

export interface IdentityRoleUpdateDto
  extends IdentityRoleCreateOrUpdateDtoBase,
  IHasConcurrencyStamp { }

export interface RoleDto extends IdentityRoleDto {
  permissions: Array<UpdatePermissionDto>;
}

export interface GetIdentityRolesInput extends PagedAndSortedResultRequestDto {
  filter?: string;
}

export interface IdentityRoleDto extends ExtensibleEntityDto<string>, IHasConcurrencyStamp {
  name: string;
  isDefault: boolean;
  isStatic: boolean;
  isPublic: boolean;
}

export interface RoleCreateDto extends Omit<IdentityRoleCreateDto, 'extraProperties'> {
  permissions: Array<UpdatePermissionDto>;
  extraProperties: {
    CustomDataPermission: string;
    DataPermission: DataPermission;
  };
}

export interface RoleUpdateDto extends Omit<IdentityRoleUpdateDto, 'extraProperties'>, IEntityDto<string>, IHasConcurrencyStamp {
  permissions: Array<UpdatePermissionDto>;
  isStatic: boolean;
  extraProperties: {
    CustomDataPermission: string;
    DataPermission: DataPermission;
  };
}
